package com.zjtaixue.o2o.util;

import com.zjtaixue.o2o.enums.ResultEnum;
import com.zjtaixue.o2o.vo.ResultVO;

public class ResultVOUtil {

    public static ResultVO success (Object object){
        ResultVO resultVO=new ResultVO();
        resultVO.setData(object);
        resultVO.setSuccess(true);
        resultVO.setCode(0);
        resultVO.setMsg("成功");
        return resultVO;
    }

    public static ResultVO success(){
        return success(null);
    }

    public static ResultVO error(Integer code,String msg){
        ResultVO resultVO=new ResultVO();
        resultVO.setMsg(msg);
        resultVO.setCode(code);
        resultVO.setSuccess(false);
        return resultVO;
    }

    public static ResultVO error(ResultEnum resultEnum){
        return error(resultEnum.getCode(),resultEnum.getMessage());
    }
}
